package org.imis.action;

import java.io.File;
import java.io.Serializable;

import org.imis.domain.Teach;
import org.imis.service.NewsManage;

import com.opensymphony.xwork2.ActionContext;

public class DeleteAction {
	private NewsManage newsManage;
    private String table;
    private String id;
    private String pageN;
    
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getTable() {
		return table;
	}
	public void setTable(String table) {
		this.table = table;
	}
	public NewsManage getNewsManage() {
		return newsManage;
	}
	public void setNewsManage(NewsManage newsManage) {
		this.newsManage = newsManage;
	}
	public String execute() throws NumberFormatException, ClassNotFoundException
	{
		if(table.equals("Teach"))
		{
			Teach teach = (Teach) newsManage.findOneList(table,Integer.parseInt(id) );
			File oldFile = new File(teach.getPicurl());
			oldFile.delete();
			newsManage.deleteByid(Class.forName("org.imis.domain."+table),(Serializable)Integer.parseInt(id));
			return "tsuccess";
		}
		newsManage.deleteByid(Class.forName("org.imis.domain."+table),(Serializable)Integer.parseInt(id));
		
		return "success";
		
	}
	public String getPageN() {
		return pageN;
	}
	public void setPageN(String pageN) {
		this.pageN = pageN;
	}
}
